Ruby 2.0.0-p0 is released

We are pleased to announce the release of Ruby 2.0.0-p0.

Ruby 2.0.0 is the first stable release of the Ruby 2.0 series, with many new features and improvements in response to the increasingly diverse and expanding demands for Ruby.

Enjoy programming with Ruby 2.0.0!

Download

What is Ruby 2.0.0

New Features

Some of the highlights:

  • Language core features
    • Keyword arguments, which give flexibility to API design
    • Module#prepend, which is a new way to extend a class
    • A literal %i, which creates an array of symbols easily
    • __dir__, which returns the dirname of the file currently being executed
    • The UTF-8 default encoding, which make many magic comments omissible
  • Built-in libraries
    • Enumerable#lazy and Enumerator::Lazy, for (possibly infinite) lazy stream
    • Enumerator#size and Range#size, for lazy size evaluation
    • #to_h, which is a new convention for conversion to Hash
    • Onigmo, which is a new regexp engine (a fork of Oniguruma)
    • Asynchronous exception handling API
  • Debug support
    • DTrace support, which enables run-time diagnosis in production
    • TracePoint, which is an improved tracing API
  • Performance improvements
    • GC optimization by bitmap marking
    • Kernel#require optimization which makes Rails startup very fast
    • VM optimization such as method dispatch
    • Float operation optimization

In addition, albeit as an experimental feature, 2.0.0 includes Refinements, which adds a new concept to Ruby's modularity.

See also NEWS for more features, improvements and details.

Compatibility

We have also taken care with the 2.0.0 design to make it compatible with 1.9. It will be easier to migrate from 1.9 to 2.0 than it was from 1.8 to 1.9. (The notable incompatibilities are described later.)

In fact, thanks to the dedicated work of third parties, some popular applications such as Rails and tDiary have been reported to work on the release candidate version of 2.0.0.

Documentation

We have also made documentation improvements which many rubyists have requested. We have added a huge amount of rdoc for modules and methods. 2.0.0 will be around 75% documented while 1.9.3 was about 60%. Also, we have added a description of Ruby's syntax. You can see:

ri ruby:syntax

Stability

Note that unlike 1.9.0, 2.0.0 IS a stable release, even though its TEENY is 0. All library authors are strongly recommended to support 2.0.0. As mentioned above, it will be comparatively easy to migrate from 1.9 to 2.0.

Ruby 2.0.0 is ready for practical use, and will absolutely improve your Ruby life.

Notes

Introductory articles

Here are some introductory articles of 2.0.0 features by third parties:

The following articles are also helpful, but outdated with regards to refinement:

Also, the recent issue of "Rubyist Magazine" includes some articles that were written by the feature authors themselves for introducing some new 2.0.0 features.

Though they will be written in Japanese, English translations are planned for the future.

Incompatibility

There are five notable incompatibilities we know of:

  • The default encoding for ruby scripts is now UTF-8 [#6679]. Some people report that it affects existing programs, such as some benchmark programs becoming very slow [ruby-dev:46547].
  • Iconv was removed, which had already been deprecated when M17N was introduced in ruby 1.9. Use String#encode, etc. instead.
  • There is ABI breakage [ruby-core:48984]. We think that normal users can/should just reinstall extension libraries. You should be aware: DO NOT COPY .so OR .bundle FILES FROM 1.9.
  • #lines, #chars, #codepoints, #bytes now returns an Array instead of an Enumerator [#6670]. This change allows you to avoid the common idiom "lines.to_a". Use #each_line, etc. to get an Enumerator.
  • Object#inspect does always return a string like #<ClassName:0x…> instead of delegating to #to_s. [#2152]

There are some comparatively small incompatibilities. [ruby-core:49119]

Status of Refinements

We have added a feature called Refinements, which adds a new concept to Ruby's modularity. However, please be aware that Refinements is still an experimental feature: we may change its specification in the future. Despite that, we would like you to play with it and give us your thoughts. Your feedback will help to forge this interesting feature.

Acknowledgment

A great many people contributed to 2.0.0. Even an incomplete acknowledgment for only a few parts of contributions became too big to insert here. Sorry but let me just add a link to the special thanks page.

Thank you all!